Skip to content

table: Allow a header row height separate from the body - #3420

Merged
madcodelife merged 2 commits into
longbridge:mainfrom
xhofe:table-header-height
Oct 9, 2026
Merged

madcodelife merged 2 commits into
longbridge:mainfrom
xhofe:table-header-height

Conversation

@xhofe

@xhofe xhofe commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

DataTable used one height for header rows and body rows, so a two-line header forced every record row to grow with it. header_row_height sets the height of each header row on its own. Body rows keep Size::table_row_height. When header_row_height is unset, header rows still use that body height, so existing tables look the same.

Page Up and Page Down used to subtract one body row as a stand-in for the header. They now subtract the full header band (header row height times the number of header rows) before dividing by the body row height. With a single header row at the body height, that is the same count as before.

Screenshot

No visual change when header_row_height is unset. The Data Table story adds a Header Row Height menu (Default / 40px / 48px) to try it.

Public API

gpui-component

  • gpui_component::table::DataTable::header_row_height(self, height: impl Into<gpui::Pixels>) -> Self — sets each header row's height independently of the body row size. Column-group rows use the same height. When unset, header rows keep Size::table_row_height().

How to Test

  • cargo check -p gpui-component --locked
  • cargo check -p gpui-component-story --locked (passed here)
  • cargo run and open the Data Table story. Scroll and use Page Up / Page Down. With Header Row Height on Default, the header and scrollbar match the previous build. Group Headers is on by default, so Page Up / Page Down now step one row less than before, because both header rows are subtracted. Switch Header Row Height to 40px or 48px to see taller header rows over unchanged body rows.
  • To try the new height: DataTable::new(&state).with_size(Size::Size(px(20.))).header_row_height(px(34.)). Header rows are 34px and body rows stay 20px. The vertical scrollbar starts below the header band.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

xhofe and others added 2 commits October 8, 2026 22:53
A taller header was forcing every body row to grow, because both bands used
Size::table_row_height. header_height sets the header band only. Page Up and
Page Down subtract that band before dividing by the body row height.

Co-authored-by: Cursor <[email protected]>
@madcodelife

Copy link
Copy Markdown
Member

Thanks for the PR!

I pushed a small follow-up. I renamed header_height to header_row_height, since the value sets the height of each header row, and also added a Header Row Height menu to the Data Table story so it's easy to try out.

@madcodelife
madcodelife enabled auto-merge (squash) October 9, 2026 03:25
@madcodelife
madcodelife disabled auto-merge October 9, 2026 03:25
@madcodelife
madcodelife enabled auto-merge (squash) October 9, 2026 03:25
@madcodelife
madcodelife merged commit 37cad32 into longbridge:main Oct 9, 2026
16 checks passed
linruohan pushed a commit to linruohan/gpui-component that referenced this pull request Oct 9, 2026
)

## Description

`DataTable` used one height for header rows and body rows, so a two-line
header forced every record row to grow with it. `header_row_height` sets
the height of each header row on its own. Body rows keep
`Size::table_row_height`. When `header_row_height` is unset, header rows
still use that body height, so existing tables look the same.

Page Up and Page Down used to subtract one body row as a stand-in for
the header. They now subtract the full header band (header row height
times the number of header rows) before dividing by the body row height.
With a single header row at the body height, that is the same count as
before.

## Screenshot

No visual change when `header_row_height` is unset. The Data Table story
adds a Header Row Height menu (Default / 40px / 48px) to try it.

## Public API

### gpui-component

- `gpui_component::table::DataTable::header_row_height(self, height:
impl Into<gpui::Pixels>) -> Self` — sets each header row's height
independently of the body row size. Column-group rows use the same
height. When unset, header rows keep `Size::table_row_height()`.

## How to Test

- `cargo check -p gpui-component --locked`
- `cargo check -p gpui-component-story --locked` (passed here)
- `cargo run` and open the Data Table story. Scroll and use Page Up /
Page Down. With Header Row Height on Default, the header and scrollbar
match the previous build. Group Headers is on by default, so Page Up /
Page Down now step one row less than before, because both header rows
are subtracted. Switch Header Row Height to 40px or 48px to see taller
header rows over unchanged body rows.
- To try the new height:
`DataTable::new(&state).with_size(Size::Size(px(20.))).header_row_height(px(34.))`.
Header rows are 34px and body rows stay 20px. The vertical scrollbar
starts below the header band.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [x] Reviewed the changes in this PR and confirmed AI generated code
(If any) is accurate.
- [ ] Passed `cargo run` for story tests related to the changes.
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific)

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Floyd Wang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@huacnlee huacnlee mentioned this pull request Oct 12, 2026
huacnlee added a commit that referenced this pull request Oct 12, 2026
## Description

Prepare v0.7.2 on `stable` from the PRs merged into `main` since v0.7.1,
leaving out every change that breaks existing consumers. `stable`
already carries #3371 and #3373; this adds the remaining compatible PRs
with `git cherry-pick -x` and bumps the workspace to 0.7.2.

### Included

- kit: Add optional gpui-fast backend (#3375)
- tooltip: Make show delay and grace period configurable with
`TooltipDefaults` (#3376)
- docs: Explain recovering focus when the focused element stops
rendering (#3386)
- diff: Add readonly patch viewer (#3378)
- kit: Use one Windows manifest with GPUI Fast (#3380)
- test: Make Progress and TitleBar findable in UI tests (#3383)
- input: Preserve selection, focus ring and context menu actions (#3382)
- diff: Add a Git history example and complete review APIs (#3388)
- text_view: Ignore gestures that stay inside one block plugin (#3390)
- text_view: Round the first and last table rows to the frame radius
(#3309)
- menu: Open a context menu with a long press on touch (#3393)
- text_view: Keep narrow table columns on one line (#3399)
- settings: Keep focus rings inside the list viewport (#3394)
- scrollable_mask: Keep rounded scroll-table corners clean at any scroll
offset (#3400)
- dialog: Add margin_top to AlertDialog (#3404)
- input: Add InputState::add_selection for programmatic multi-cursor
(#3403)
- text_selection: Stop writing selection state on every frame (#3407)
- table: Make the sort icon a labelled button (#3396)
- table: Report visible row ranges of one row or none (#3397)
- dialog: Support configurable entrance animations (#3405)
- docs: Explain the open_dialog builder and footer contracts (#3406)
- dock: Hand the focus to the tab that replaces a closed one (#3409)
- dropdown_button: Add A11y names for the menu trigger (#3410)
- text, resizable: Stop notifying state that did not change (#3418)
- editor: Add on-demand completion commands (#3411)
- table: Clear a right-clicked cell's outline on the next click (#3413)
- tab: Scroll a clicked tab into view with the next one peeking (#3419)
- table: Allow a header row height separate from the body (#3420)
- menu: Focus a context menu before its first frame (#3422)
- text: Preserve logical selection across presentation changes (#3421)
- text: Keep inline HTML mark highlights in Markdown (#3425)
- input: Anchor completion/code-action popups to the current frame's
caret (#3412)
- input: Run custom context menu builders after releasing the input
(#3433)
- input: Keep auto-grow rows fitted when the limits change (#3430)
- text: Paint TextView selection under the glyphs (#3439)

Already on `stable`: #3371, #3373.

### Excluded (Breaking Changes)

- #3432 motion: `Easing::sample` now returns values outside `[0, 1]` for
overshooting curves.
- #3415 tab: new `TabVariant::Folder` breaks exhaustive matches.
- #3402 kit: pointer helpers now keep held modifiers; nested
context-menu behavior changes in tests.
- #3384 test: `TestWindowExt` gains required methods.
- #3302 resizable: `ResizeHandle::on_drag` takes `&T` instead of
`Rc<T>`.
- #3389, #3395, #3398 webview: wrapper API changes, `gpui-wry` →
`gpui-webview` rename, and the GPUI Fast requirement.

#3411, #3405 and #3396 have a Breaking Changes section that reads "None"
and are included. #3376 only deprecates `TooltipRequest::placement`, and
#3397 / #3382 change behavior compatibly, so they are included too.

### Adaptations

- `crates/kit/tests/collections.rs` and `crates/kit/tests/rendering.rs`:
conflict resolutions drop the tests that belong to #3402 and keep each
backported PR's own test.
- `test: Keep backported tests on the v0.7.1 test API`: the menu and
completion tests from #3422 and #3412 used `find_all` and
`pointer_down`/`pointer_up` from #3384/#3402. They now query
`gpui_kit::base::test_support::snapshots` and dispatch mouse events
directly.
- `kit: Prepare v0.7.2`: workspace version bump; `Cargo.lock` only
updates workspace members.

## Public API

No new public API beyond what the included PRs add; each lists its items
in its own `## Public API` section (notably #3375, #3376, #3378, #3388,
#3403, #3404, #3405, #3411, #3420).

## How to Test

- `cargo clippy --workspace --all-targets -- --deny warnings` passes on
Linux.
- `cargo test -p gpui-kit --features "test-support component assets"
--test collections --test menu --test input` passes on Linux.
- The macOS-only `rendering` test (#3439 adds one case, the count is
updated to 11) was not run.

AI-assisted: the backport, conflict resolution and test adaptations were
done with Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Floyd Wang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gustave <[email protected]>
Co-authored-by: luren <[email protected]>
Co-authored-by: Ylin <[email protected]>
Co-authored-by: ihavecoke <[email protected]>
Co-authored-by: Lorenzo <[email protected]>
Co-authored-by: MR. XIE <[email protected]>
Co-authored-by: xxww0098 <[email protected]>
Co-authored-by: Sola 🌙🤖 <[email protected]>
Co-authored-by: Sola <[email protected]>
Co-authored-by: Andy Hsu <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Floyd Wang <[email protected]>
Co-authored-by: Daiki Tomioka <[email protected]>
Co-authored-by: Henrik Øgård <[email protected]>
Co-authored-by: Henrik Øgård <[email protected]>
Co-authored-by: Endless <[email protected]>
Co-authored-by: John Costa <[email protected]>
Co-authored-by: Alexander <[email protected]>
Co-authored-by: Cesar Talén <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants